package com.woniuxy.elasticsearch.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.math.BigDecimal;

/**
 * @Author zhangyong
 * @Date 2021/8/16 0016下午 4:06
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Document(indexName = "woniumall")  //指定索引的名字   设置对应关系
public class Goods {
    @Id    //指定主键
    @Field(name = "id",type = FieldType.Keyword)   //关键字、主键
    private int id;     //商品id

    //analyzer  插入数据时，使用的分词策略，建议ik_max_word  尽可能拆
    //searchAnalyzer  查询时使用哪个分词策略，建议用ik_smart  可以提高命中率
    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
    private String name;

    @Field(type = FieldType.Text)
    private String goodsno;

    @Field(type = FieldType.Text)
    private String publisher;

    @Field  //如果不写类型，可以自动转换
    private String pubtime;

    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
    private String description;

    @Field
    private BigDecimal salesprice;

    @Field
    private int salenums;
}
